//
//  PinTuanXQViewController.m
//  1243
//
//  Created by ym on 16/7/6.
//  Copyright © 2016年 1243. All rights reserved.
//

#import "PinTuanXQViewController.h"
#import "PinTuanXQTopTableViewCell.h"
#import "PinTuanNextTableViewCell.h"
#import "PinTuanMiaoShuTableViewCell.h"
#import "CanTuanTableViewCell.h"
#import "QuCanTuanViewController.h"
#import "choseView.h"
#import "AttributeView.h"
@interface PinTuanXQViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)UITableView *tableView;
@end

@implementation PinTuanXQViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationController.navigationBar.translucent = NO;
    [self CreattableView];
}

- (void)CreattableView{
    self.tableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] bounds]  style:UITableViewStylePlain];
    [self.view addSubview:_tableView];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.separatorStyle = UITableViewCellSelectionStyleNone;
    _tableView.contentInset = UIEdgeInsetsMake(0, 0, 50, 0);

}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 4;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
#warning 头部
    if (indexPath.section == 0) {
        static NSString *identifier= @"PinTuanXQTopTableViewCell";
        PinTuanXQTopTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell==nil) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"PinTuanXQTopTableViewCell" owner:nil options:nil] lastObject];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        return cell;
    }else if (indexPath.section == 1){
#warning 选择规格
        static NSString *identifier= @"PinTuanNextTableViewCell";
        PinTuanNextTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell==nil) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"PinTuanNextTableViewCell" owner:nil options:nil] lastObject];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        return cell;
    }else if(indexPath.section == 2){
        static NSString *identifier= @"PinTuanMiaoShuTableViewCell";
        PinTuanMiaoShuTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell==nil) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"PinTuanMiaoShuTableViewCell" owner:nil options:nil] lastObject];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        return cell;
    }else{
        static NSString *identifier= @"CanTuanTableViewCell";
        CanTuanTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell==nil) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"CanTuanTableViewCell" owner:nil options:nil] lastObject];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        return cell;
        
    }
  
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    if (section != 3) {
        return 1;
    }else{
        return 10;
    }
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        return 200;
    }else if(indexPath.section == 1){
        return 40;
    }else if(indexPath.section == 2){
        return 150;
    }else{
        return 120;
    }
    
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.section == 3) {
        QuCanTuanViewController *a = [[QuCanTuanViewController alloc] init];
        [self pushForm:self.navigationController pushToAndHidden:a];
        
    }else if (indexPath.section == 1){
        
        NSDictionary *dic = @{
                              @"key":@"颜色",
                              @"value":@[@"dadasdasdas",@"1",@"eqw",@"eqweqwqwe",@"1111111",@"111112222"]
                              };
        
        NSArray *arr = @[dic];
        
        choseView *a = [[choseView alloc] init];
        [self.view addSubview:a];
        a.frame = FRAME;
        a.backgroundColor = [UIColor whiteColor];
        a.arrDic = arr;
        
        
    }
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 50)];
        view.backgroundColor = COLOR(228, 228, 234, 1);
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, WIDTH, 40)];
    [view addSubview:label];
    label.text = @"以下小伙伴正在发起团购，您可直接参与";
    label.textAlignment = NSTextAlignmentCenter;
    label.font = [UIFont systemFontOfSize:15];
    return view;
    
    
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 3) {
        return 50;
    }else{
        return 0;
    }
}
//tabBar 隐藏
- (void)pushForm:(UINavigationController *)pushForm pushToAndHidden:(UIViewController *)pushToVC
{
    [pushToVC setHidesBottomBarWhenPushed:YES];
    [pushForm pushViewController:pushToVC animated:YES];
    
}
@end
